package com.azusa.xbiao.dao;

import com.azusa.xbiao.entity.Cart;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CartDao extends JpaRepository<Cart,Integer> {

    @Query("from Cart where id=?1 and gIds=?2 and isPay=?3")
    Cart findByIdAndGids(int id,int gid,int isPay);

    @Query("from Cart where id=?1 and isPay=?2 order by addDate desc")
    List<Cart> selectAll(int id,int isPay);

    @Query(value = "update cart set is_pay=?3,`count`=?4 where g_ids=?2 and id=?1",nativeQuery = true)
    @Modifying
    void settle(int cid,int gid,int isPay,int count);
}
